package com.fp.m7.shared.services;

import java.util.Date;
import java.util.List;

import com.fp.m7.shared.dto.CommentDto;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;

public interface CommentServiceAsync {

    void blog(String nickname, int pageNumber, AsyncCallback<List<CommentDto>> callback);

    void blog(String nickname, Date from, Date to, AsyncCallback<List<CommentDto>> callback);

    void blog(int pageNumber, AsyncCallback<List<CommentDto>> callback);

    void blog(Date from, Date to, AsyncCallback<List<CommentDto>> callback);

    void timeline(int pageNumber, AsyncCallback<List<CommentDto>> callback);

    void postComment(String content, AsyncCallback<Boolean> callback);

    void deleteComment(CommentDto commentDto, AsyncCallback<Boolean> callback);

    /**
     * Utility class to get the RPC Async interface from client-side code
     */
    public static final class Util {
        private static CommentServiceAsync instance;

        public static CommentServiceAsync getInstance() {
            if (instance == null) {
                instance = (CommentServiceAsync) GWT.create(CommentService.class);
            }
            return instance;
        }

        private Util() {
            // Utility class should not be instantiated
        }
    }
}
